﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.Text;
using TV4Home.Server.TVEInteractionLibrary;
using TV4Home.Server.TVEInteractionLibrary.Interfaces;

namespace TV4Home.Server.CoreService.ConsoleHost
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("TV4Home.Server.CoreService.ConsoleHost starting....");
            Console.WriteLine();

            Console.WriteLine("Opening service host...");
            ServiceHost serviceHost = new ServiceHost(typeof(TVEInteraction));

            foreach (ServiceEndpoint se in serviceHost.Description.Endpoints)
            {
                if (se.Name == "JsonEndpoint")
                    se.Behaviors.Add(new WebHttpWithCustomExceptionHandling());
            }

            serviceHost.Open();

            Console.WriteLine();
            Console.WriteLine("Finished. Press any key to exit.");
            Console.ReadLine();
        }
    }
}
